<template>
  <div class="bg-ff">
    <div
      v-for="(item, index) in list"
      :key="index"
      class="padding-40 border-bottom flex justify-between align-center word-all"
      @click="change(item.id)"
    >
      {{item.title}}
      <input class="scale" type="radio" :value="index" :checked="item.id == radio" />
    </div>

    <div class="margin-t80">
      <div class="sure bg-ff0 text-ff text-center letter-10" @click="sure">保存</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      radio: null
    };
  },
  mounted() {
    document.querySelector('html').style.backgroundColor = "#ffffff";
    this.list = this.$route.params.list;
    for (let i in this.list) {
      if (this.$route.params.radio == this.list[i].title) {
        this.radio = this.list[i].id;
      }
    }
  },
  methods: {
    change(id) {
      this.radio = id;
    },
    sure() {
      let type = this.$route.params.type;
      let value = this.radio;
      if (!value && this.$route.params.notnull == 1) {
        this.$toast("请选择完整~");
        return false;
      }
      this.$axios.post( "/wap/personal/editUserInfo", {
        token: window.localStorage.getItem("token"),
        key: type,
        value: value
      }).then(res => {
        this.$toast(res.data.msg);
        if (res.data.code == 0) {
          this.$router.go(-1);
        }
      });
    }
  }
};
</script>

<style scoped>
input {
  width: auto;
}
</style>
<style>
html {
  background: white;
}
</style>